# Maintainer: Sven-Hendrik Haase <sh@lutzhaase.com>
# Contributor: Urs Wolfer <uwolfer @ fwo.ch>

pkgname=blobby2
pkgver=1.0
arch=('loong64' 'x86_64')
pkgrel=4
pkgdesc="A beach ball game with blobs of goo"
url="http://sourceforge.net/projects/blobby/"
license=('GPL')
depends=('sdl2' 'physfs' 'libgl')
makedepends=('cmake' 'boost' 'mesa' 'zip')
source=(https://downloads.sourceforge.net/blobby/$pkgname-linux-$pkgver.tar.gz
        ostream-include.patch
        $pkgname.desktop
        $pkgname.png)
sha512sums=('b9e36de4a44e482c9d0742b95034c2979d7a51512ac5e3fd8f4933655132028dfc9642c3580e5523b5b95d38acc169932d24808cee236710731c2571321337fa'
            '9373f67f619b089c374396cde8240a9667497bb8aae12e891da6bcbb2fc2543f382c3d2d7c5f4c0be16843f942d24553d790333b972276a4bc8cd98c444eb936'
            '715b4337dc868cf51ca69c01476e1fa3a3dd631397fca91dc55f4d45e241b35dd0850f4be3e12a0afd7c2a94b6adfa623c633d4ce79ca6098f8e7ee6e69b3917'
            '8b7b85d8e02f8174054a724752d5d40c609820be1e5e06c4868dc0e383d4cf4befe73ab0e910e9838b70be3f7e106ee71ef1e04f0560fdde7bff6ca473fa81ec')

prepare() {
  cd $srcdir/blobby-$pkgver
  patch -Np2 -i ../ostream-include.patch # r1542 upstream
  sed -i "s|data|/usr/share/blobby|g" src/main.cpp
  sed -i "s|file\(filename\)|file(\"/usr/share/blobby\" + filename|g" src/main.cpp
}

build() {
  cd $srcdir/blobby-$pkgver
  cmake -DCMAKE_INSTALL_PREFIX=/usr
  make
}

package() {
  cd $srcdir/blobby-$pkgver

  make DESTDIR=$pkgdir install

  install -Dm644 data/Icon.bmp ${pkgdir}/usr/share/blobby/Icon.bmp

  # install .desktop file and icon
  install -dm755 $pkgdir/usr/share/{applications,pixmaps}
  install -m644 $srcdir/$pkgname.desktop $pkgdir/usr/share/applications
  install -m644 $srcdir/$pkgname.png $pkgdir/usr/share/pixmaps
}
